﻿namespace Frameworks
{
    using System.Text.RegularExpressions;

    public class StringUtility
    {
        /// <summary>
        /// 移除前缀
        /// </summary>
        /// <param name="value"></param>
        /// <param name="prefix">前缀字符</param>
        /// <returns></returns>
        public static string RemovePrefix(string value, string prefix)
        {
            string strRegex = @"^(" + prefix + ")";
            return Regex.Replace(value, strRegex, "");
        }

        /// <summary>
        /// 移除后缀
        /// </summary>
        /// <param name="value"></param>
        /// <param name="suffix">后缀字符</param>
        /// <returns></returns>
        public static string RemoveSuffix(string value, string suffix)
        {
            string strRegex = @"(" + suffix + ")" + "$";
            return Regex.Replace(value, strRegex, "");
        }
    }
}
